<?php

set_include_path(implode(PATH_SEPARATOR,
    array(
        get_include_path(),
        '..',
        dirname(dirname(dirname(__FILE__)))
    )));

require_once 'components/utils/debug_utils.php';

Warning::BeginSuppress(PHPWarning::$Deprecated);
Warning::BeginSuppress(PHPWarning::$Strict);

require_once 'tests/simpletest/autorun.php';
require_once 'database_engine/commands.php';
require_once 'database_engine/condition.php';
require_once 'database_engine/command_builders/update_command.php';

class UpdateCommandBuilderTests extends UnitTestCase
{
    public function testCreateSimpleUpdateCommand()
    {
        $commandBuilder = new UpdateCommandBuilder();
        $commandBuilder->SetTable('test_table');

        $commandBuilder->SetFieldValue(FieldName::Short('id'), Literal::Number(2));
        $commandBuilder->SetFieldValue(FieldName::Short('value'), Literal::String('string value'));

        $commandBuilder->AddCondition(
            new BinaryCondition(FieldName::Short('id'), BinaryOperator::$Equals, Literal::Number(1)));

        $this->assertEqual(
            'UPDATE test_table SET id = 2, value = \'string value\' WHERE (id = 1)',
            $commandBuilder->GetSql()
        );
    }
}

?>